package com.ruoyi.system.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.DeclarationJTReport;
import com.ruoyi.system.service.IDeclarationJTReportService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 军团报表Controller
 * 
 * @author triangle
 * @date 2022-08-13
 */
@Controller
@RequestMapping("/system/declarationJTReport")
public class DeclarationJTReportController extends BaseController
{
    private String prefix = "system/declarationJTReport";

    @Autowired
    private IDeclarationJTReportService declarationJTReportService;

    @RequiresPermissions("system:declarationJTReport:view")
    @GetMapping()
    public String declarationJTReport()
    {
        return prefix + "/declarationJTReport";
    }

    /**
     * 查询军团报表列表
     */
    @RequiresPermissions("system:declarationJTReport:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(DeclarationJTReport declarationJTReport)
    {
        startPage();
        List<DeclarationJTReport> list = declarationJTReportService.selectDeclarationJTReportList(declarationJTReport);
        return getDataTable(list);
    }

    /**
     * 导出军团报表列表
     */
    @RequiresPermissions("system:declarationJTReport:export")
    @Log(title = "军团报表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(DeclarationJTReport declarationJTReport)
    {
        List<DeclarationJTReport> list = declarationJTReportService.selectDeclarationJTReportList(declarationJTReport);
        ExcelUtil<DeclarationJTReport> util = new ExcelUtil<DeclarationJTReport>(DeclarationJTReport.class);
        return util.exportExcel(list, "军团报表数据");
    }

    /**
     * 新增军团报表
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存军团报表
     */
    @RequiresPermissions("system:declarationJTReport:add")
    @Log(title = "军团报表", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(DeclarationJTReport declarationJTReport)
    {
        return toAjax(declarationJTReportService.insertDeclarationJTReport(declarationJTReport));
    }

    /**
     * 修改军团报表
     */
    @RequiresPermissions("system:declarationJTReport:edit")
    @GetMapping("/edit/{decId}")
    public String edit(@PathVariable("decId") Long decId, ModelMap mmap)
    {
        DeclarationJTReport declarationJTReport = declarationJTReportService.selectDeclarationJTReportByDecId(decId);
        mmap.put("declarationJTReport", declarationJTReport);
        return prefix + "/edit";
    }

    /**
     * 修改保存军团报表
     */
    @RequiresPermissions("system:declarationJTReport:edit")
    @Log(title = "军团报表", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(DeclarationJTReport declarationJTReport)
    {
        return toAjax(declarationJTReportService.updateDeclarationJTReport(declarationJTReport));
    }

    /**
     * 删除军团报表
     */
    @RequiresPermissions("system:declarationJTReport:remove")
    @Log(title = "军团报表", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(declarationJTReportService.deleteDeclarationJTReportByDecIds(ids));
    }
}
